// pages/draw/drawRank/index.js
var common = require("../../../public.js");
Page({

  data: {
    userInfo: '',
    token: '',
    drawId: '', // 抽奖id
    rankList: [],
    listBoxHeight: 0
  },
  onLoad: function (options) {
    let that = this
    wx.getStorage({
      key: 'user',
      success: function (res) {
        that.setData({
          userInfo: res.data.user,
          token: res.data.token,
          drawId: options.drawId,
        }, () => {
          that.getRankList()
        })
      }
    })
    // let query = wx.createSelectorQuery();
    // query.select('.rankBanner').boundingClientRect(rect => {
    //   let clientHeight = rect.height;
    //   console.log(clientHeight)
    //   let winHeight = wx.getSystemInfoSync().windowHeight
    //   that.setData({
    //     listBoxHeight: winHeight - clientHeight
    //   })
    // }).exec();
  },
  getRankList() {
    let that = this
    let tempJson = {
      userId: that.data.userInfo.id,
      token: that.data.token,
      drawId: that.data.drawId
    }
    common.wxRequest("/storeDraw/getStoreDrawRankList", "post", tempJson, 'application/x-www-form-urlencoded', function (res) {
      console.log(res.rankList)
      that.setData({
        rankList: res.data
      })
    })

  }

})